Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more unit tests #366

Merged
merged 16 commits into from
Mar 17, 2017
Merged

Add more unit tests #366

merged 16 commits into from
Mar 17, 2017

Conversation

erayd
Copy link
Contributor

@erayd erayd commented Mar 2, 2017

What

New Coverage

  • Validator::coerce
  • SchemaStorage::getUriRetriever
  • SchemaStorage::getUriResolver
  • Most of Iterator\ObjectIterator
  • ConstraintError
  • Entity\JsonPointer::__construct (invalid type for $value)
  • Constraints\TypeConstraint::validateTypeNameWording
  • Constraints\TypeConstraint::validateType (throws exception on invalid type)
  • Various parts of Uri\UriRetriever
  • Most of Uri\Retrievers\FileGetContents
  • Uri\Retrievers\Curl

New Ignores

  • strlen in StringConstraint::strlen - because mbstring is available on all test platforms, so this line is never hit.
  • $http_response_header in Uri\Retrievers\FileGetContents::retrieve - because $http_response_header is set in the local method scope and is inaccessible to tests.
  • The \RuntimeException in \Uri\Retrievers\Curl::__construct - because curl_init will always be available to the testsuite, so this will never be thrown.

Roadblocks

Why

Because better test coverage is always a good thing. The goal is to get up to 100% coverage in this PR.

Note that in cases where there is a test for an unfixed bug, Travis will fail. This will auto-resolve when the bugfix is merged and this PR is rebased to include it.

@erayd erayd changed the title Add test coverage for coercion API Add more unit tests Mar 2, 2017
@erayd erayd changed the base branch from master to 6.0.0-dev March 2, 2017 21:48
@erayd
Copy link
Contributor Author

erayd commented Mar 2, 2017

Note that the SchemaStorage test makes two remote HTTP requests for the official spec. Merging #362 will automatically make these local.

@erayd erayd changed the title Add more unit tests [WIP] Add more unit tests Mar 3, 2017
@erayd erayd changed the title [WIP] Add more unit tests Add more unit tests Mar 7, 2017
@erayd
Copy link
Contributor Author

erayd commented Mar 8, 2017

Yay! This PR now has 100% test coverage of 6.0.0, with the exception of the two items listed in the Roadblocks section above.

Note that there are currently two bugs that cause failed tests in this PR - fixes for those are in #370 and #372.

Is there anything else people would like to see tests added for before this is merged?

@erayd
Copy link
Contributor Author

erayd commented Mar 8, 2017

scr-20170308-195202

@shmax
Copy link
Collaborator

shmax commented Mar 8, 2017

Bravo, very impressive. 👏

@erayd
Copy link
Contributor Author

erayd commented Mar 8, 2017

Thanks :-).

@bighappyface bighappyface removed the WIP label Mar 17, 2017
@bighappyface
Copy link
Collaborator

Cheers

@bighappyface bighappyface merged commit 705dcbd into jsonrainbow:6.0.0-dev Mar 17, 2017
erayd added a commit to erayd/json-schema that referenced this pull request Mar 17, 2017
* Add test coverage for coercion API

* Complete test coverage for SchemaStorage

* Add test coverage for ObjectIterator

* Add exception test for JsonPointer

* MabeEnum\Enum appears to use singletons - add testing const

* Don't check this line for coverage

mbstring is on all test platforms, so this line will never be reached.

* Add test for TypeConstraint::validateTypeNameWording()

* Add test for exception on TypeConstraint::validateType()

* PHPunit doesn't like an explanation with its @codeCoverageIgnore...

* Add various tests for UriRetriever

* Add tests for FileGetContents

* Add tests for JsonSchema\Uri\Retrievers\Curl

* Add missing bad-syntax test file

* Restrict ignore to the exception line only

* Fix exception scope
@erayd erayd mentioned this pull request Mar 17, 2017
erayd added a commit to erayd/json-schema that referenced this pull request Mar 17, 2017
* Add test coverage for coercion API

* Complete test coverage for SchemaStorage

* Add test coverage for ObjectIterator

* Add exception test for JsonPointer

* MabeEnum\Enum appears to use singletons - add testing const

* Don't check this line for coverage

mbstring is on all test platforms, so this line will never be reached.

* Add test for TypeConstraint::validateTypeNameWording()

* Add test for exception on TypeConstraint::validateType()

* PHPunit doesn't like an explanation with its @codeCoverageIgnore...

* Add various tests for UriRetriever

* Add tests for FileGetContents

* Add tests for JsonSchema\Uri\Retrievers\Curl

* Add missing bad-syntax test file

* Restrict ignore to the exception line only

* Fix exception scope
@erayd erayd deleted the more-tests branch March 17, 2017 19:41
bighappyface pushed a commit that referenced this pull request Mar 22, 2017
* Add URI translation for retrieval & add local copies of spec schema

* Add use line for InvalidArgumentException & adjust scope (#372)

Fixes issue #371

* add quiet option (#382)

* add quiet option

* use verbose instead of quiet

* add quiet option

* always output dump-schema

* always output dump-schema-url

* fix typo and ws

* [BUGFIX] Add provided schema under a dummy / internal URI (fixes #376) (#378)

* Add provided schema under a dummy / internal URI (fixes #376)

In order to resolve internal $ref references within a user-provided
schema, SchemaStorage needs to know about the schema. As user-supplied
schemas do not have an associated URI, use a dummy / internal one instead.

* Remove dangling use

* Change URI to class constant on SchemaStorage

* Add option to disable validation of "format" constraint (#383)

* Add more unit tests (#366)

* Add test coverage for coercion API

* Complete test coverage for SchemaStorage

* Add test coverage for ObjectIterator

* Add exception test for JsonPointer

* MabeEnum\Enum appears to use singletons - add testing const

* Don't check this line for coverage

mbstring is on all test platforms, so this line will never be reached.

* Add test for TypeConstraint::validateTypeNameWording()

* Add test for exception on TypeConstraint::validateType()

* PHPunit doesn't like an explanation with its @codeCoverageIgnore...

* Add various tests for UriRetriever

* Add tests for FileGetContents

* Add tests for JsonSchema\Uri\Retrievers\Curl

* Add missing bad-syntax test file

* Restrict ignore to the exception line only

* Fix exception scope

* Allow the schema to be an associative array (#389)

* Allow the schema to be an associative array

Implements #388.

* Use json_decode(json_encode()) for array -> object cast

* Skip exception check on PHP versions < 5.5.0

* Skip test on HHVM, as it's happy to encode resources

* Enable FILTER_FLAG_EMAIL_UNICODE for email format if present (#398)

* Don't throw exceptions until after checking anyOf / oneOf (#394)

Fixes #393

* Fix infinite recursion on some schemas when setting defaults (#359) (#365)

* Don't try to fetch files that don't exist

Throws an exception when the ref can't be resolved to a useful file URI,
rather than waiting for something further down the line to fail after
the fact.

* Refactor defaults code to use LooseTypeCheck where appropriate

* Test for not treating non-containers like arrays

* Update comments

* Rename variable for clarity

* Add CHECK_MODE_ONLY_REQUIRED_DEFAULTS

If CHECK_MODE_ONLY_REQUIRED_DEFAULTS is set, then only apply defaults
if they are marked as required.

* Workaround for $this scope issue on PHP-5.3

* Fix infinite recursion via $ref when applying defaults

* Add missing second test for array case

* Add test for setting a default value for null

* Also fix infinite recursion via $ref for array defaults

* Move nested closure into separate method

* $parentSchema will always be set when $name is, so don't check it

* Handle nulls properly - fixes issue #377

* Add option to also validate the schema (#357)

* Remove stale files from #357 (obviated by #362) (#400)

* Stop #386 sneaking in alongside another PR backport
erayd added a commit to erayd/json-schema that referenced this pull request Mar 22, 2017
* Add test coverage for coercion API

* Complete test coverage for SchemaStorage

* Add test coverage for ObjectIterator

* Add tests for ConstraintError

* Add exception test for JsonPointer

* MabeEnum\Enum appears to use singletons - add testing const

* Don't check this line for coverage

mbstring is on all test platforms, so this line will never be reached.

* Add test for TypeConstraint::validateTypeNameWording()

* Add test for exception on TypeConstraint::validateType()

* PHPunit doesn't like an explanation with its @codeCoverageIgnore...

* Add various tests for UriRetriever

* Add tests for FileGetContents

* Add tests for JsonSchema\Uri\Retrievers\Curl

* Add missing bad-syntax test file

* Restrict ignore to the exception line only

* Fix exception scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants